#ifndef H3D_LUA_BINDINGS_H
#define H3D_LUA_BINDINGS_H

#include "Horde3D.h"
#include "lua.hpp"

// Note: the following functions have not had lua interfaces generated for them yet
// questionable functions for auto-generation
// DLL const_char_ptr h3dGetMessage( int *level, float *time ); // return values through pointers
// DLL float h3dGetOption( H3DOptions::List param ); // cast to H3DOptions::List
// DLL bool h3dSetOption( H3DOptions::List param, float value ); // cast to H3DOptions::List
// DLL float h3dGetStat( H3DStats::List param, bool reset ); // cast to H3DOptions::List
// DLL bool h3dLoadResource( H3DRes res, const_char_ptr data, int size ); // need to get non null terminatd string from lua
// DLL void h3dGetNodeTransform( H3DNode node, float *tx, float *ty, float *tz, // returns values through pointers

// DLL void h3dGetNodeTransMats( H3DNode node, const float **relMat, const float **absMat ); // return matrices through pointers!
// DLL void h3dSetNodeTransMat( H3DNode node, const float *mat4x4 ); // need to extract matrix from lua

// // return values through pointers
// DLL void h3dGetNodeAABB( H3DNode node, float *minX, float *minY, float *minZ, float *maxX, float *maxY, float *maxZ );
// DLL bool h3dGetCastRayResult( int index, H3DNode *node, float *distance, float *intersection ); // intersection is a vector?
// DLL void h3dGetCameraProjMat( H3DNode cameraNode, float *projMat ); // projMat is a matrix return value through a pointer

// // these shouldn't even really have lua interfaces...
// DLL void *h3dMapResStream( H3DRes res, int elem, int elemIdx, int stream, bool read, bool write );
// DLL void h3dUnmapResStream( H3DRes res );
// DLL bool h3dGetPipelineRenderTargetData( H3DRes pipelineRes, const char *targetName,
                                         // int bufIndex, int *width, int *height, int *compCount,
                                         // float *dataBuffer, int bufferSize );

void pushH3DNode(lua_State* L, H3DNode n);
void pushH3DRes(lua_State* L, H3DRes n);
H3DNode unboxH3DNode(lua_State* L, int pos);
H3DRes unboxH3DRes(lua_State* L, int pos);

class H3DLuaBindings
{
public:
	static void pushStaticFuncs(lua_State* L);
	//static void makeTable(lua_State* L, const char* tabName);
	//static void setVal(lua_State* L, const char* valName, int val);
	static void pushH3dEnums(lua_State* L);

	// These are manually written functions
	static int li_h3dutDumpMessages(lua_State* L);
	
	// Paste these into the header:
	// Automatically generated functions.
	static int li_h3dSetNodeTransform(lua_State* L);
	static int li_h3dGetVersionString(lua_State* L);
	static int li_h3dCheckExtension(lua_State* L);
	static int li_h3dGetError(lua_State* L);
	static int li_h3dInit(lua_State* L);
	static int li_h3dRelease(lua_State* L);
	static int li_h3dSetupViewport(lua_State* L);
	static int li_h3dRender(lua_State* L);
	static int li_h3dFinalizeFrame(lua_State* L);
	static int li_h3dClear(lua_State* L);
	static int li_h3dShowOverlay(lua_State* L);
	static int li_h3dClearOverlays(lua_State* L);
	static int li_h3dGetResType(lua_State* L);
	static int li_h3dGetResName(lua_State* L);
	static int li_h3dGetNextResource(lua_State* L);
	static int li_h3dFindResource(lua_State* L);
	static int li_h3dAddResource(lua_State* L);
	static int li_h3dCloneResource(lua_State* L);
	static int li_h3dRemoveResource(lua_State* L);
	static int li_h3dIsResLoaded(lua_State* L);
	static int li_h3dUnloadResource(lua_State* L);
	static int li_h3dGetResElemCount(lua_State* L);
	static int li_h3dFindResElem(lua_State* L);
	static int li_h3dGetResParamI(lua_State* L);
	static int li_h3dSetResParamI(lua_State* L);
	static int li_h3dGetResParamF(lua_State* L);
	static int li_h3dSetResParamF(lua_State* L);
	static int li_h3dGetResParamStr(lua_State* L);
	static int li_h3dSetResParamStr(lua_State* L);
	static int li_h3dQueryUnloadedResource(lua_State* L);
	static int li_h3dReleaseUnusedResources(lua_State* L);
	static int li_h3dCreateTexture(lua_State* L);
	static int li_h3dSetShaderPreambles(lua_State* L);
	static int li_h3dSetMaterialUniform(lua_State* L);
	static int li_h3dGetNodeType(lua_State* L);
	static int li_h3dGetNodeParent(lua_State* L);
	static int li_h3dSetNodeParent(lua_State* L);
	static int li_h3dGetNodeChild(lua_State* L);
	static int li_h3dAddNodes(lua_State* L);
	static int li_h3dRemoveNode(lua_State* L);
	static int li_h3dSetNodeActivation(lua_State* L);
	static int li_h3dCheckNodeTransFlag(lua_State* L);
	static int li_h3dGetNodeParamI(lua_State* L);
	static int li_h3dSetNodeParamI(lua_State* L);
	static int li_h3dGetNodeParamF(lua_State* L);
	static int li_h3dSetNodeParamF(lua_State* L);
	static int li_h3dGetNodeParamStr(lua_State* L);
	static int li_h3dSetNodeParamStr(lua_State* L);
	static int li_h3dFindNodes(lua_State* L);
	static int li_h3dGetNodeFindResult(lua_State* L);
	static int li_h3dCastRay(lua_State* L);
	static int li_h3dCheckNodeVisibility(lua_State* L);
	static int li_h3dAddGroupNode(lua_State* L);
	static int li_h3dAddModelNode(lua_State* L);
	static int li_h3dSetupModelAnimStage(lua_State* L);
	static int li_h3dSetModelAnimParams(lua_State* L);
	static int li_h3dSetModelMorpher(lua_State* L);
	static int li_h3dAddMeshNode(lua_State* L);
	static int li_h3dAddJointNode(lua_State* L);
	static int li_h3dAddLightNode(lua_State* L);
	static int li_h3dAddCameraNode(lua_State* L);
	static int li_h3dSetupCameraView(lua_State* L);
	static int li_h3dAddEmitterNode(lua_State* L);
	static int li_h3dAdvanceEmitterTime(lua_State* L);
	static int li_h3dHasEmitterFinished(lua_State* L);
	static int li_h3dDoNothing(lua_State* L);
};

#endif
